package com.atguigu.lease.web.admin.custom.converter;

import com.atguigu.lease.model.enums.ItemType;


import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * @author 86188
 * @version v1.0
 * @project ShangTingApartment
 * @Date 2025/7/7 18:00
 * @company []
 * @description
 */
@Component
public class IntegerToItemTypeConverter  implements Converter<String, ItemType> {

    @Override
    public ItemType convert(String source) {
        if (ItemType.APARTMENT.getCode()== Integer.parseInt(source)){
            return ItemType.APARTMENT;
        }else if (ItemType.ROOM.getCode()==Integer.parseInt(source)){
            return ItemType.ROOM;
        }
        throw new RuntimeException("无效的状态值！");
    }

}
